/**
 * 
 */
package com.gr.experimental.model.impl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.gr.experimental.model.BuiltInElements;
import com.gr.experimental.model.Distribution;
import com.gr.experimental.model.MEBNConstants;
import com.gr.experimental.model.MFrag;
import com.gr.experimental.model.RVClass;
import com.gr.experimental.model.RVClassInfluence;
import com.gr.experimental.model.UID;

/**
 * @author Karol Banczyk
 *
 */
class BuiltInElementsImpl implements BuiltInElements {

	public static final BuiltInElements THIS_INSTANCE = new BuiltInElementsImpl();
	
	public static final UID TRUE = new UIDImpl(MEBNConstants.TRUE);
	public static final UID FALSE = new UIDImpl(MEBNConstants.FALSE);
	public static final UID ABSURD = new UIDImpl(MEBNConstants.ABSURD);

	public static final List<UID> BOOLEAN_UIDS = Arrays.asList(TRUE, FALSE, ABSURD);

	public static final List<UID> UIDS = Arrays.asList(TRUE, FALSE, ABSURD);

	public static Map<String, UID> ALIASES = createAliasMap();
	
	private static Map<String, UID> createAliasMap() {
		Map<String, UID> aliases = new HashMap<String, UID>();
//		aliases.put(MEBNConstants.TRUE, TRUE);
//		aliases.put(MEBNConstants.FALSE, FALSE);
//		aliases.put(MEBNConstants.ABSURD, ABSURD);
		
		for (UID uid: UIDS) {
			aliases.put("" + uid.getValue(), uid);
		}
		
		return Collections.unmodifiableMap(aliases);
	}
	
	// logical MFrags
	public static MFrag logicalORMFrag ;
	
	
	
	static {

		// creating the identity MFrag
		{
			
//			identityMFrag = new MFrag("identity");
			
			Distribution idDistr = new Distribution() {

				@Override
				public double[] getProbabilities(
						List<RVClassInfluence> partialWorldState) {
					// TODO Auto-generated method stub
					return null;
				}

				@Override
				public double[] getProbabilities() {
					// TODO Auto-generated method stub
					return null;
				}

				@Override
				public List<UID> getDomain() {
					// TODO Auto-generated method stub
					return null;
				}

				@Override
				public List<RVClass> getConditionRVClasses() {
					// TODO Auto-generated method stub
					return null;
				}
				
			};
			
			// the identity rv has to be updated 
			// by the reasoner or 
			// used only as a marking object
			// anyway it has to be understood by the reasoner
			// in a specific way
			RVClassImpl identityRV = new RVClassImpl("identity", new ArrayList<UID>(),0);
			
//			identityMFrag.residentNodes.add(identityRV);
		}
		{
//			logicalORMFrag = new MFragImpl("OR");
			
//			RVClass orRV = new RVClass("OR");
//			// the identity random variable
//			//
//			OVariable a = new OVariable("a");
//			OVariable b = new OVariable("b");
//			logicalORMFrag.ovars.add(a);
//			logicalORMFrag.ovars.add(b);
			
			//logicalORMFrag.inputNodes.
		}
		
	}



	@Override
	public UID getAbsurdUID() {
		return ABSURD;
	}



	@Override
	public Map<String, UID> getAliasMap() {
		return ALIASES;
	}



	@Override
	public List<UID> getBooleanUIDs() {
		return BOOLEAN_UIDS;
	}



	@Override
	public List<UID> getBuiltInUIDs() {
		return UIDS;
	}



	@Override
	public UID getFalseUID() {
		return FALSE;
	}



	@Override
	public UID getTrueUID() {
		return TRUE;
	}



	@Override
	public UID getUIDForAlias(String alias) {
		return ALIASES.get(alias);
	}


}